
<script setup>
import { ref} from 'vue';

// 定义 props
const props = defineProps({
  username: {
    type: String,
    default: '',
  },
  password: {
    type: String,
    default: '',
  },
});

// 定义 emits
const emit = defineEmits(['update:username', 'update:password', 'login']);

// 双向绑定
const username = ref(props.username);
const password = ref(props.password);

// 处理登录按钮点击事件
const handleLogin = () => {
  emit('login', { username: username.value, password: password.value });
};
</script>

<template>
  <div class="login-simple">
    <div class="form-group">
      <label for="username">用户名</label>
      <input
          type="text"
          id="username"
          v-model="username"
          placeholder="请输入用户名"
          class="input-field"
      />
    </div>
    <div class="form-group">
      <label for="password">密码</label>
      <input
          type="password"
          id="password"
          v-model="password"
          placeholder="请输入密码"
          class="input-field"
      />
    </div>
    <button type="button" class="login-button" @click="handleLogin">登录</button>
  </div>
</template>


<style scoped>
.login-simple {
  width: 100%;
  max-width: 400px; /* 限制最大宽度 */
  padding: 40px; /* 增加内边距 */
  background-color: #ffffff;
  border-radius: 12px; /* 更大的圆角 */
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.form-group {
  margin-bottom: 24px; /* 增加间距 */
  text-align: left;
}

label {
  display: block;
  margin-bottom: 8px;
  color: #555;
  font-size: 14px;
  font-weight: bold;
}

.input-field {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  color: #333;
  background-color: #f9f9f9;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.input-field:focus {
  border-color: #409eff;
  outline: none;
  box-shadow: 0 0 8px rgba(64, 158, 255, 0.3);
}

.input-field::placeholder {
  color: #999;
}

.login-button {
  width: 100%;
  padding: 12px;
  background-color: #409eff;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.login-button:hover {
  background-color: #2980b9;
}
</style>